<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true">
      <el-form-item label="日期">
        <el-date-picker
          v-model="queryParams.value1"
          type="date"
          placeholder="选择日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="出库时间">
        <el-date-picker
          v-model="queryParams.value1"
          type="date"
          placeholder="选择日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="出库单号" prop="roleName">
        <el-input
          v-model="queryParams.roleName"
          placeholder="请输入"
          clearable
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料仓库" prop="status">
        <el-select
          v-model="queryParams.status"
          placeholder="请选择"
          clearable
          style="width: 240px"
        >
          <el-option
            v-for="dict in options"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="业务类别" prop="status">
        <el-select
          v-model="queryParams.status"
          placeholder="请选择"
          clearable
          style="width: 240px"
        >
          <el-option
            v-for="dict in options"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="单位类型" prop="status">
        <el-select
          v-model="queryParams.status"
          placeholder="请选择"
          clearable
          style="width: 240px"
        >
          <el-option
            v-for="dict in options"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="维保单号" prop="roleName">
        <el-input
          v-model="queryParams.roleName"
          placeholder="请输入"
          clearable
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="备注" prop="roleName">
        <el-input
          v-model="queryParams.roleName"
          placeholder="请输入"
          clearable
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button @click="handleAdd" size="mini">新增</el-button>    
        <!-- <el-button size="mini">查看</el-button> -->
        <el-button size="mini">编辑</el-button>       
        <el-button size="mini" @click="handleDelete">删除</el-button>
        <el-button size="mini" @click="check">提交修改</el-button>
        <el-button size="mini" @click="submit">提交删除</el-button>
        <el-button size="mini" @click="uploadAnnex">附件</el-button>
        <el-button @click="handlePrint" size="mini">打印</el-button>
      </el-col>
    </el-row>
    <el-table v-loading="loading" show-summary :data="list" @selection-change="handleSelectionChange" @row-click="rowSelect">
      <el-table-column type="selection" width="80" align="center" />
      <el-table-column label="提交" prop="roleName" />
      <el-table-column label="出库单号" prop="roleKey"  />
      <el-table-column label="日期" prop="roleSort" />
      <el-table-column label="出库时间" prop="roleSort" width="100" />
      <el-table-column label="物料仓库" prop="roleSort" width="100" />
      <el-table-column label="维保单号" prop="roleSort" />
      <el-table-column label="数量" prop="roleSort" />
      <el-table-column label="业务类别" prop="roleSort" />
      <el-table-column label="单位类别" prop="roleSort" width="100" />
      <el-table-column label="领料部门" prop="roleSort" width="100" />
      <el-table-column label="制单人" prop="roleSort" />
      <el-table-column label="备注" prop="roleSort" />
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <el-table style="margin-top: 40px;" v-loading="loading1" :data="list1">
      <el-table-column label="是否收费" prop="roleName" />
      <el-table-column label="物料名称" prop="roleName" />
      <el-table-column label="物料大类" prop="roleKey"  />
      <el-table-column label="物料规格" prop="roleSort" />
      <el-table-column label="数量" prop="roleSort" width="100" />
      <el-table-column label="单位" prop="roleSort" width="100" />
      <el-table-column label="费用项目" prop="roleSort" />
      <el-table-column label="费用类别" prop="roleSort" />
      <el-table-column label="无税单价" prop="roleSort" width="100" />
      <el-table-column label="无税金额" prop="roleSort" width="100" />
      <el-table-column label="销售单价" prop="roleSort" />
      <el-table-column label="销售金额" prop="roleSort" />
      <el-table-column label="税率" prop="roleSort" />
      <el-table-column label="税额" prop="roleSort" />
      <el-table-column label="领料人" prop="roleSort" width="100" />
      <el-table-column label="用途" prop="roleSort" width="100" />
      <el-table-column label="入库批号" prop="roleSort" />
      <el-table-column label="设备代码" prop="roleSort" />
      <el-table-column label="领用设备" prop="roleSort" />
      <el-table-column label="货架号" prop="roleSort" />
    </el-table>
    <!-- 附件对话框 -->
    <el-dialog title="附件上传" :visible.sync="annexOpen" width="500px" append-to-body>
      <imageUpload v-model="imageFile" />
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="annexSubmit">确 定</el-button>
        <el-button @click="annexOpen=false">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 打印对话框 -->
    <el-dialog title="打印" :visible.sync="printOpen" width="800px" append-to-body>
      <el-row>
        <el-col style="text-align: center;">XX有限公司物料入库表</el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="8">单据号：DJH323242345</el-col>
        <el-col :span="8">日期：2023-11-11</el-col>
        <el-col :span="8">物料仓库：XX仓库</el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="8">采购人：张三</el-col>
        <el-col :span="8">制单人：李四</el-col>
        <el-col :span="8">备注：</el-col>
      </el-row>
      <el-table :data="printList">
        <el-table-column label="类别" prop="roleName" />
        <el-table-column label="物料名称" prop="roleKey"  />
        <el-table-column label="规格" prop="roleSort" />
        <el-table-column label="数量" prop="roleSort" width="100" />
        <el-table-column label="单位" prop="roleSort" width="100" />
        <el-table-column label="单价" prop="roleSort" />
        <el-table-column label="金额" prop="roleSort" />
        <el-table-column label="用途" prop="roleSort" width="100" />
      </el-table>

      <pagination
        v-show="printTotal>0"
        :total="printTotal"
        :page.sync="printParams.pageNum"
        :limit.sync="printParams.pageSize"
        @pagination="getPrintList"
      />
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="printSubmit">确 定</el-button>
        <el-button @click="printOpen=false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listRole } from "@/api/system/role";

export default {
  data() {
    return {
      ids: [],
      // 下拉数据
      options: [],
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 表格数据
      list: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        roleName: undefined,
        status: undefined,
        num: undefined
      },
      // 附件上传
      annexOpen: false,
      imageFile: [],
      // 打印
      printOpen: false,
      printList: [],
      printTotal: 0,
      printParams: {
        pageNum: 1,
        pageSize: 10
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    // 多选
    handleSelectionChange() {

    },
    /** 查询角色列表 */
    getList() {
      this.loading = true;
      listRole(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
          this.list = response.rows;
          this.total = response.total;
          this.loading = false;
        }
      );
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 核对
    check() {
      this.$modal.confirm('是否确认提交当前单据？')
        .then(() => {

        })
    },
    // 提交
    submit() {
      this.$modal.confirm('是否确认提交当前单据？')
        .then(() => {

        })
    },
    // 表格行点击
    rowSelect(row) {
      this.loading1 = true
      this.list1 = []
      this.loading1 = false
    },
    // 新增
    handleAdd() {
      this.title = '新增'
      this.open = true
      this.$emit('change', 'Form')
    },
    // 查看
    handleView() {
      this.title = '查看'
      this.isReadOnly = true
      this.open = true
      this.$emit('change', 'Form')
    },
    // 编辑
    handleEdit() {
      this.title = '编辑'
      this.open = true
      this.$emit('change', 'Form')
    },
    // 删除
    handleDelete() {
      this.$modal
        .confirm("确定要删除该记录吗？")
        .then(() => {
          
        })
    },
    // 附件上传
    uploadAnnex() {
      this.annexOpen = true
    },
    annexSubmit() {

    },
    // 打印
    getPrintList() {

    },
    handlePrint() {
      this.printOpen = true
    },
    printSubmit() {

    }
  }
};
</script>
